package com.yunyao.common.constant.enums;

import lombok.Getter;

/**
 * @author xingjishuai
 * @date 2024-07-12
 */
@Getter
public enum SaleContractType {
    MASTER(0, "主合同"),
    SALE(1, "补充合同");
    private final int type;
    private final String description;

    SaleContractType(int type, String description) {
        this.type = type;
        this.description = description;
    }

    /**
     * 可以根据 type 获取枚举实例
     */
    public static String getDescriptionByType(int type) {
        for (SaleContractType status : SaleContractType.values()) {
            if (status.getType() == type) {
                return status.getDescription();
            }
        }
        return null;
    }

    /**
     * 可以根据 description 获取枚举实例
     */
    public static int getTypeByDesc(String description) {
        for (SaleContractType status : SaleContractType.values()) {
            if (status.getDescription().equalsIgnoreCase(description)) {
                return status.getType();
            }
        }
        return -1;
    }

}
